
//
//  LVPropManageVc.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/3/7.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVPropManageVc.h"
#import "HYVerCustomSlideViewController.h"
#import "LVEncounterAndPropVc.h"
#import "HYOptionalView.h"
#import "LVCustomAlertView.h"

@interface LVPropManageVc ()<HYVerCustomSlideViewControllerDelegate,HYVerCustomSlideViewControllerDataSource>
@property (nonatomic, strong) HYVerCustomSlideViewController *verSlideViewController;
@property (nonatomic, strong) HYOptionalView *optionalView;

@end

@implementation LVPropManageVc
- (void)viewDidLoad {
    [super viewDidLoad];

    WeakSelf(weakSelf);
    self.optionalView.titles = @[@"遇到",@"道具"];
    self.optionalView.optionalViewItemClickHandle = ^(HYOptionalView *optialView, NSString *title, NSInteger currentIndex){
        weakSelf.verSlideViewController.seletedIndex = currentIndex;
    };
    [self HY_setUpNavRightItemTitle:nil itemImage:@"empty" handle:^(NSString *leftItemTitle) {
        LVCustomAlertView *alert = [[LVCustomAlertView alloc] initWithTitle:@"你确定要删除所有动态吗？" cancel:@"取消" sure:@"确认"];
        [alert showInView:self.view.window];
        WeakSelf(weakSelf);
        [alert setupSureBlock:^BOOL{

            HYBaseTableViewController *seletedVc = (HYBaseTableViewController *)weakSelf.verSlideViewController.seletedChildVc;
            [seletedVc.dataArray removeAllObjects];
            [seletedVc HY_reloadData];

            return YES;
        }];
        [alert setupCancelBlock:^BOOL{

            
            return YES;
        }];
    }];

    self.navigationItem.titleView = self.optionalView;

    [self.verSlideViewController reloadData];
}
#pragma mark HYVerCustomSlideViewControllerDelegate
- (void)verCustomSlideViewController:(HYVerCustomSlideViewController *)slideViewController slideIndex:(NSInteger)slideIndex
{

}
#pragma mark HYVerCustomSlideViewControllerDataSource
/** 子控制器*/
- (UIViewController *)verSlideViewController:(HYVerCustomSlideViewController *)slideViewController viewControllerAtIndex:(NSInteger)index
{
    LVEncounterAndPropVc *encounterAndProp = [[LVEncounterAndPropVc alloc] init];

    return encounterAndProp;
}
/** 子控制器数量*/
- (NSInteger)numberOfChildViewControllersInVerSlideViewController:(HYVerCustomSlideViewController *)slideViewController
{
    return 2;
}
- (void)verCustomSlideViewController:(HYVerCustomSlideViewController *)slideViewController slideOffset:(CGPoint)slideOffset{
    self.optionalView.contentOffset = slideOffset;
}
#pragma mark 创建滚动视图控制器
- (HYVerCustomSlideViewController *)verSlideViewController {
    if (!_verSlideViewController) {
        HYVerCustomSlideViewController *slide = [[HYVerCustomSlideViewController alloc] init];
        slide.isTransversal = YES;
        slide.canScroll = YES;
        [self addChildVc:slide];
        _verSlideViewController = slide;
        slide.delgate = self;
        slide.dataSource = self;
    }
    return _verSlideViewController;
}
#pragma mark 滑动条
- (HYOptionalView *)optionalView {
    if (!_optionalView) {
        HYOptionalView *optional = [[HYOptionalView alloc] init];
        optional.showBottomLine = NO;
        optional.frame = CGRectMake(0, 0, 120, 40);
        _optionalView = optional;
        optional.backgroundColor = kWhiteColor;
        optional.normalColor = KGrayColor;
        optional.seletedColor = KMainColor;
    }
    return _optionalView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
